package com.karileet.nokia.meeting.profile;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Vibrator;
import android.util.Log;
 
public class SMSReceiver extends BroadcastReceiver {
	private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
	
	@Override
	public void onReceive(Context arg0, Intent intent) {
		SharedPreferences p = arg0.getSharedPreferences(MainActivity.PREFS_NAME, 0);
		if (intent.getAction().equals(ACTION) && p.getBoolean("profile", false)) {
			Log.d(MainActivity.APP, "Recieved SMS, playing sound!");
			SoundManager sm = new SoundManager(arg0);
			//vibrate since SMS doesn't vibrate when conf is set to vibrate
			if (p.getBoolean("vibrate", false)) {
				Vibrator v = (Vibrator) arg0.getSystemService(Context.VIBRATOR_SERVICE);
				v.vibrate(1000);
			}
	    	sm.play(); //Dependent of music, video & other media volume setting
		}
	}
}